﻿using MangoMes.Commont.DapperHelps;
using MangoMes.Commont.Domain.Client;
using MangoMes.Commont.DTOs;
using MangoMes.Commont.Infrastructures.Interfaces;
using MediatR;

namespace MangoMes.Write.API.Applications.Clientss
{
    public class ClientManagementBackHandler : IRequestHandler<ClientManagementBackCommand, ResultsDTO<ClientManagement>>
    {
        private readonly IBateRepository<ClientManagement> clients;
        public ClientManagementBackHandler(IBateRepository<ClientManagement> clients)
        {
            this.clients = clients; 
        }
        /// <summary>
        /// 客户管理
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<ResultsDTO<ClientManagement>> Handle(ClientManagementBackCommand request, CancellationToken cancellationToken)
        {
            var list = new ResultsDTO<ClientManagement>() { Code = 0 };
            var str = "select * from clientmanagement where ClientId=" + request.ClientId + "";
            var per=new ClientManagement();
            DapperHelper helper=new DapperHelper();
            list.Data= clients.GetAll(str,per, helper.MangoMesWrite).ToList();
            return list;
        }
    }
}
